/******************************************************************************
* File description: MaintenanceTabWidgetYingGuang.qml
* Function: 维护：荧光Tab页
* Current Version: 1.0.0
* Author: 张宇轩
* Date: 2024-08-07
*  -----
*  Copyright by 博坤生物 .
 *****************************************************************************/
import QtQuick 2.14
import QtQuick.Layouts 1.14
import QtQuick.Controls 2.14

Item {
    id: root

    /* property 定义开始 */
    // 私有
    property var _tabBarModel: []

    // 信号

    // 函数

    /* property 定义结束 */

    TabBar {
        id: tabBar
        width: parent.width
        height: 54
        anchors {
            top: parent.top
            left: parent.left
            topMargin: 8
        }

        background: Rectangle {
            color: "transparent"
        }

        // 占位按钮，不可操作
        TabButton {
            width: 16
            height: 54
            enabled: false
            background: Rectangle { color: "transparent" }
        }

        Repeater {
            model: root._tabBarModel

            TabButton {
                width: tabBtnlabel.implicitWidth
                height: index === tabBar.currentIndex-1 ? 54 : 44
                anchors.bottom: parent.bottom

                // 文字
                contentItem: Label {
                    id: tabBtnlabel
                    height: parent.height
                    verticalAlignment: Text.AlignVCenter
                    horizontalAlignment: Text.AlignHCenter
                    anchors.horizontalCenter: parent.horizontalCenter
                    font.pixelSize: index === tabBar.currentIndex-1 ? 18 : 16
                    color: index === tabBar.currentIndex-1 ? "#FF222222" : "#FFFFFF"
                    text: qsTr(modelData)
                    leftPadding: 24
                    rightPadding: 24
                }

                // 背景
                background: Rectangle{
                    color: index === tabBar.currentIndex-1 ? "#FFFFFFFF" : "#FFA3BACC"
                }
            }
        }

        onCurrentIndexChanged: {
            // 设置页面变化
            contentStackLayout.currentIndex = tabBar.currentIndex - 1
        }

        Component.onCompleted: {
            // 规避占位按钮，从1开始
            tabBar.currentIndex = 1
        }
    }

    // 内容区
    Rectangle {
        id: contentCon
        width: parent.width
        height: parent.height - tabBar.height - tabBar.anchors.topMargin
        anchors {
            top: tabBar.bottom
        }
        color: "#FFFFFFFF"

        StackLayout {
            id: contentStackLayout
            anchors.fill: parent

            // 开关激发光
            MaintenanceYingGuang2JiFaGuang {
                id: jiFaGuang

                property string title: "开关激发光"

                Layout.fillWidth: true;
                Layout.fillHeight: true
            }

            // 荧光值读取
            MaintenanceYingGuang2YingGuangZhi {
                id: yingGuangZhi

                property string title: "荧光值读取"

                Layout.fillWidth: true;
                Layout.fillHeight: true
            }

            // 水平检测位置校正
            MaintenanceYingGuang2ShuiPingJianCe {
                id: shuiPingJianCe

                property string title: "水平检测位置校正"

                Layout.fillWidth: true;
                Layout.fillHeight: true
            }

            // 孔位检测位置校正
            MaintenanceYingGuang2KongWeiJianCe {
                id: kongWeiJianCe

                property string title: "孔位检测位置校正"

                Layout.fillWidth: true;
                Layout.fillHeight: true
            }

            // 光强设置
            MaintenanceYingGuang2GuangQiang {
                id: guangQiang

                property string title: "光强设置"

                Layout.fillWidth: true;
                Layout.fillHeight: true
            }

            // 检测偏差
            MaintenanceYingGuang2JianCePianCha {
                id: jianCePianCha

                property string title: "检测偏差"

                Layout.fillWidth: true;
                Layout.fillHeight: true
            }

            // 背景偏差
            MaintenanceYingGuang2BeiJingPianCha {
                id: beiJingPianCha

                property string title: "背景偏差"

                Layout.fillWidth: true
                Layout.fillHeight: true
            }
        }

        Component.onCompleted: {
            // 设置tabbar
            var tabBarComponentsTitleList = []
            var childrenList = contentStackLayout.children

            for(let i = 0; i < contentStackLayout.count; i++)
            {
                tabBarComponentsTitleList.push(childrenList[i].title)
            }

            root._tabBarModel = tabBarComponentsTitleList
        }
    }
}
